package com.bingxue.edu.teacher.controller;

import com.bingxue.edu.framework.common.model.PageQuery;
import com.bingxue.edu.framework.common.model.Pagination;
import com.bingxue.edu.framework.common.model.Response;
import com.bingxue.edu.management.auth.EmployeeAuthUtil;
import com.bingxue.edu.management.shop.model.query.SellRecordQuery;
import com.bingxue.edu.management.shop.model.resp.SellRecordResp;
import com.bingxue.edu.management.shop.service.SellRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author panbo
 * @since 2024/11/29
 */
@Tag(name = "教师端小程序-我的业绩")
@RestController
@RequestMapping("/t/sell-record")
@RequiredArgsConstructor
public class TeacherSellRecordController {

    private final SellRecordService sellRecordService;

    @Operation(summary = "分页查询销售顾问业绩")
    @GetMapping("/page")
    public Response<Pagination<SellRecordResp>> getSellRecordPage(SellRecordQuery query, PageQuery pageQuery) {
        String currentUserId = EmployeeAuthUtil.getCurrentUserId();
        query.setSellerId(List.of(currentUserId));
        return Response.success(Pagination.of(sellRecordService.getSellRecordPage(query, pageQuery)));
    }
}
